
import { getCouponCenterList, setUserCoupon } from '../../services/user';
Page({
  data: {
    tickets: [
      {
        id: 0,
        price: 30,
        baseline: 300,
        startAt: '2019.4.01',
        endAt: '2019.12.31',
        action: 0
      },
      {
        id: 0,
        price: 30,
        baseline: 300,
        startAt: '2019.4.01',
        endAt: '2019.12.31',
        action: 1
      },
      {
        id: 0,
        price: 30,
        baseline: 300,
        startAt: '2019.4.01',
        endAt: '2019.12.31',
        action: 2
      },
    ],
    activeId: 0,
  },
  onLoad() {
    my.setNavigationBar({
      title: '领券中心',
      backgroundColor: '#4BA3F9'
    })
    this.getCouponCenterList()
  },
  getCouponCenterList() {
    getCouponCenterList({}).then(res => {
      if (res.code == "000000") {
        this.setData({ tickets: res.data })
      }

    })
  },
  onTap(event) {
    setUserCoupon({ couponId: event.target.dataset.id }).then(res => {
      if (res.code == '000000') {
        this.onLoad()
      }
    })
  },
  onShow() {
  

  },
  onTabItemTap(id) {
    console.log(id);
    this.setData({ activeId: id });
  },
});
